class ObjectValueService{
    private StringBuffer lock = new StringBuffer("123");
    public  void testMethod(){
        try{
            synchronized(lock){
                System.out.println(Thread.currentThread().getName()+
                        "  begin "+System.currentTimeMillis());
                //改变lock对象的值
                lock.append("456");
                Thread.sleep(2000);
                System.out.println(Thread.currentThread().getName()+
                        "  end "+System.currentTimeMillis());
            }
        }catch(InterruptedException e){
            e.printStackTrace();
        }
    }
}
